/*set working directory*/
/*ssc install blindschemes*/

/*Figure 1.1: Number of INGO Foundings per Year, 1900-2022*/
clear
import delimited "Data/wingo.csv"
rename name Name
rename founded Founded
rename country CountryTerritoryHQ
generate wingo=1
keep Name Founded CountryTerritoryHQ wingo
tempfile wingos
save `wingos'
clear
import excel "Data/NGOs_AllCountries", sheet("Sheet1") firstrow
keep Name Founded CountryTerritoryHQ
generate wingo=0
append using `wingos'
drop if Founded==.
gen count=1
collapse (sum) count, by(CountryTerritoryHQ Founded)
label variable count "Foundings"
label variable Founded "year"
drop if Founded<1900
line count Founded if CountryTerritoryHQ=="USA", xlabel(1900(30)2020) title({bf: United States}) xtitle("") name(usa) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="UK", xlabel(1900(30)2020) title({bf: United Kingdom}) xtitle("") name(uk) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="France", xlabel(1900(30)2020) title({bf: France}) xtitle("") name(france) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="Germany", xlabel(1900(30)2020) title({bf: Germany}) xtitle("") name(germany) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="Belgium", xlabel(1900(30)2020) title({bf: Belgium}) xtitle("") name(belgium) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="Canada", xlabel(1900(30)2020) title({bf: Canada}) xtitle("") name(canada) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="Australia", xlabel(1900(30)2020) title({bf: Australia}) xtitle("") name(australia) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="South Africa", xlabel(1900(30)2020) title({bf: South Africa}) xtitle("") name(safrica) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
line count Founded if CountryTerritoryHQ=="India", xlabel(1900(30)2020) title({bf: India}) xtitle("") name(india) nodraw scale(1.2) scheme(plotplain) lwidth(medthick)
graph combine usa uk france germany belgium canada australia safrica india
graph export "Figures/Figure1-1v2.pdf", as(pdf) replace
graph drop usa uk france germany belgium canada australia safrica india


/*Table 1.1: Number of INGOs per Country, 20 Largest Countries*/
clear
import delimited "Data/wingo.csv"
replace country="USA" if country=="United States" | country=="United States of America"
replace country="UK" if country=="United Kingdom"
replace country="France" if country=="FRANCE"
replace country="Germany" if country=="German Democratic Republic" | country=="Germany FR"
replace country="Korea Rep" if country=="Korea South"
rename name Name
rename founded Founded
rename country CountryTerritoryHQ
generate wingo=1
keep Name Founded CountryTerritoryHQ wingo
tempfile wingos
save `wingos'
clear
import excel "Data/NGOs_AllCountries", sheet("Sheet1") firstrow
keep Name Founded CountryTerritoryHQ
generate wingo=0
append using `wingos'
gen count=1
drop if CountryTerritoryHQ==""
collapse (sum) count, by(CountryTerritoryHQ)
egen sumcount=sum(count)
gen proportion=count/sumcount
gsort -count
list CountryTerritoryHQ count proportion in 1/20
